<template>
  <div class="advertise-place" :style="{width:width+60+'px'}">
    <div class="advertise-head">
      <div class="advertise-name">
        <span class="name">{{advertiseName}}</span>
        <span class="size">{{width}}*{{height}}</span>
      </div>
      <div class="advertise-tool">
        <el-button type="success" size="medium" v-if="images.length">待发布</el-button>
        <el-button type="primary" size="medium" v-if="images.length" @click="setAdvertise">设置</el-button>
        <el-button type="primary" size="medium" v-else>新增</el-button>
      </div>
    </div>
    <div class="advertise-tips">
      <i class="iconfont iconprompt"></i>{{description}}<i>图片等比缩放展示</i>
    </div>
    <el-carousel v-if="images.length" class="advertise-picture" :height="height + 'px'" :autoplay="false">
      <el-carousel-item v-for="(img) in images" :key='img.id'>
        <img :style="{ width: width+'px', height: height + 'px' }" :src="img.url" alt="">
      </el-carousel-item>
    </el-carousel>
    <div v-else class="empty" :style="{width:width+'px',height:height+'px'}">+虚位以待</div>
    <!-- <ul  class="advertise-picture">
      <li v-for="(img,index) in images" :key='index'><a href=""><img :style="{ width: width+'px', height: height + 'px' }" src="~/assets/images/banner.png" alt=""></a></li>
    </ul> -->
  </div>
</template>

<script>
export default {
  props:{
    advertiseId:{
      type:Number,
      default:0
    },
    advertiseName: {
      type: String,
      default:'轮播图'
    },
    description:{
      type:String,
      default:'建议图片最多不要超过 6 张，太多会分散用户注意力！'
    },
    width: {
      type: Number,
      default:400,
    },
    height: {
       type: Number,
      default:200
    },
    images: {
      type:Array,
      default:function(){
        return []
      }
    }
  },
  methods:{
    setAdvertise (){
      this.$emit('setAdvertise',this.advertiseId);
    }
  }
}
</script>

<style scoped lang="scss">
.advertise-place{
  margin:24px 24px 0 0;
  display: inline-block;
  vertical-align: bottom;
  padding:23px 30px 40px;
  background: #fff;
  border-radius: 4px;
  .advertise-head{
      position: relative;
  }
  .advertise-name{
    position: relative;
    display: inline-block;
    height:32px;
    line-height: 32px;
    .name{
      display: inline-block;
      font-size: 18px;
      color: #0F1B41;
    }
    .size{
      position: absolute;
      top:-4px;
      left:100%;
      font-size: 13px;
      color: #5A7180;
      line-height: 13px;
    }
  }
  .advertise-tool{
    position: absolute;
    top:0;
    right:0;
  }
  .advertise-tips{
    margin:8px 0 29px;
    font-size: 12px;
    color: #A4ADC8;
    line-height: 12px;
    .iconfont{
        margin-right:8px;
    }
    i{
        font-size:12px;
        color: #FF6B00;
    }
  }
  .advertise-picture{
      img{
          width:100%;
          display: block;
      }
  }
  .empty{
    height:70px;
    width:100%;
    line-height:70px;
    text-align: center;
    border:1px dotted #A4ADC8;
    font-size: 14px;
    color: #A4ADC8;
    cursor: pointer;
  }
}
</style>